package cn.itrip.auth.service;

import cn.itrip.beans.pojo.ItripUser;

public interface TokenService {

    /**
     * 会话超时时间
     */
    public final static int SESSION_TIMEOUT=2*60*60;//默认2h
    /**
     * 置换保护时间
     */
    public final static int REPLACEMENT_PROTECTION_TIMEOUT=60*60;//默认1h
    /**
     * 旧token延迟过期时间
     */
    public final static int REPLACEMENT_DELAY=2*60;//默认2min

    /**
     * 生成token
     * @param agent
     * @param user
     * @return
     */
    public String generateToken(String agent,ItripUser user) throws Exception;

    /**
     * 保存到redis
     * @param token
     * @param user
     */
    public void save(String token,ItripUser user) throws Exception;

    /**
     * 验证token是否有效
     * @param agent
     * @param token
     * @return
     */
    public boolean validate(String agent,String token) throws Exception;

    public void delete(String token) throws Exception;

    public String reloadToken(String agent, String token) throws Exception;
}
